package com.open.capacity.point.feign.fallback;

import com.open.capacity.common.web.Result;
import com.open.capacity.point.feign.UserFeignClient;
import com.open.capacity.common.auth.details.LoginAppUser;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class UserFeignClientFallback implements FallbackFactory<UserFeignClient> {
    @Override
    public UserFeignClient create(Throwable throwable) {
        return new UserFeignClient() {
            @Override
            public LoginAppUser getLoginAppUser() {
                log.error("user-center服务调用出现问题", throwable);
                return new LoginAppUser();
            }

            @Override
            public Result updateTitleByUserIdAndPoints(Long userId, Double points, String typeCode) {
                log.error("user-center服务调用出现问题", throwable);
                return Result.failed("服务调用出现问题");
            }
        };
    }

}
